package lv.imho.client.view;

import lv.imho.client.model.DataSourceTransferObject;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;

/**
 * Control that represents data source.
 * 
 * @author Igors Gulbinskis
 */
public class DataSourceComponent extends HorizontalPanel {
	
	private final String ICON_WIDTH  = "20px";	
	private final String ICON_HEIGHT = "20px";
	
	private DataSourceTransferObject dataSource;
	private CheckBox                 checkBox;
	
	public DataSourceComponent(DataSourceTransferObject dataSource) {
		super();
		
		this.dataSource = dataSource;
		DOM.setStyleAttribute(getElement(), "padding", "3px");
		
		initChildComponents();
	}
	
	private void initChildComponents() {
		checkBox = new CheckBox();
		// add(checkBox);
		
		Image icon = new Image("img/rss-icon.png");
		icon.setSize(ICON_WIDTH, ICON_HEIGHT);
		add(icon);
		
		Anchor anchor = new Anchor(dataSource.getName(), dataSource.getUrl());
		DOM.setStyleAttribute(anchor.getElement(), "padding", "3px");
		add(anchor);
	}
	
	public CheckBox getCheckBox() {
		return checkBox;
	}
		
}
